<?php
// 本类由系统自动生成，仅供测试用途
namespace Home\Controller;
use Think\Controller;

class LoginController extends Controller {

    public function index(){
        $this->display();
    }

    public function loginHandle(){
        $name = strtolower(I('name'));
        if($name == null){
            $this->error('没输入');
        }
        if($data = M('user')->where(array('name' => $name))->find())
        {
            cookie('id',$data['id']);
            cookie('name',$name);
            $this->success('登录成功',U('Index/index'));
        }else{
            $this->error('没找到该用户');
        }
    }

    public function logoutHandle(){
        cookie('id',null);
        cookie('name',null);
        $this->success('登出成功',U('Index/index'));
    }
}